/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.cmu.mism.dgjava.data.models.option.impl;

import edu.cmu.mism.dgjava.data.models.option.*;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class OptionModelFactoryImpl extends EFactoryImpl implements OptionModelFactory {
	/**
	 * Creates the default factory implementation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static OptionModelFactory init() {
		try {
			OptionModelFactory theOptionModelFactory = (OptionModelFactory)EPackage.Registry.INSTANCE.getEFactory("edu.cmu.mism.dgjava.data"); 
			if (theOptionModelFactory != null) {
				return theOptionModelFactory;
			}
		}
		catch (Exception exception) {
			EcorePlugin.INSTANCE.log(exception);
		}
		return new OptionModelFactoryImpl();
	}

	/**
	 * Creates an instance of the factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OptionModelFactoryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EObject create(EClass eClass) {
		switch (eClass.getClassifierID()) {
			case OptionModelPackage.DERIVITIVES: return createDerivitives();
			case OptionModelPackage.EQUITY: return createEquity();
			case OptionModelPackage.CURRENCY: return createCurrency();
			case OptionModelPackage.INDEX: return createIndex();
			case OptionModelPackage.FUTURES: return createFutures();
			case OptionModelPackage.PRICING_MODEL: return createPricingModel();
			case OptionModelPackage.EUROPEAN_TYPE: return createEuropeanType();
			case OptionModelPackage.AMERICAN_TYPE: return createAmericanType();
			case OptionModelPackage.BINOMIAL_EUROPEAN: return createBinomialEuropean();
			case OptionModelPackage.BINOMIAL_AMERICAN: return createBinomialAmerican();
			case OptionModelPackage.OPTION_CALCULATION_RESULT: return createOptionCalculationResult();
			case OptionModelPackage.MONTE_CARLO_SIMULATION: return createMonteCarloSimulation();
			case OptionModelPackage.IMPLICIT_FINITE_DIFFERENCE: return createImplicitFiniteDifference();
			case OptionModelPackage.BLACK_SCHOLES: return createBlackScholes();
			default:
				throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object createFromString(EDataType eDataType, String initialValue) {
		switch (eDataType.getClassifierID()) {
			case OptionModelPackage.BASE_TYPE:
				return createBaseTypeFromString(eDataType, initialValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String convertToString(EDataType eDataType, Object instanceValue) {
		switch (eDataType.getClassifierID()) {
			case OptionModelPackage.BASE_TYPE:
				return convertBaseTypeToString(eDataType, instanceValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Derivitives createDerivitives() {
		DerivitivesImpl derivitives = new DerivitivesImpl();
		return derivitives;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Equity createEquity() {
		EquityImpl equity = new EquityImpl();
		return equity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Currency createCurrency() {
		CurrencyImpl currency = new CurrencyImpl();
		return currency;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Index createIndex() {
		IndexImpl index = new IndexImpl();
		return index;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Futures createFutures() {
		FuturesImpl futures = new FuturesImpl();
		return futures;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PricingModel createPricingModel() {
		PricingModelImpl pricingModel = new PricingModelImpl();
		return pricingModel;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EuropeanType createEuropeanType() {
		EuropeanTypeImpl europeanType = new EuropeanTypeImpl();
		return europeanType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AmericanType createAmericanType() {
		AmericanTypeImpl americanType = new AmericanTypeImpl();
		return americanType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BinomialEuropean createBinomialEuropean() {
		BinomialEuropeanImpl binomialEuropean = new BinomialEuropeanImpl();
		return binomialEuropean;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BinomialAmerican createBinomialAmerican() {
		BinomialAmericanImpl binomialAmerican = new BinomialAmericanImpl();
		return binomialAmerican;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OptionCalculationResult createOptionCalculationResult() {
		OptionCalculationResultImpl optionCalculationResult = new OptionCalculationResultImpl();
		return optionCalculationResult;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MonteCarloSimulation createMonteCarloSimulation() {
		MonteCarloSimulationImpl monteCarloSimulation = new MonteCarloSimulationImpl();
		return monteCarloSimulation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ImplicitFiniteDifference createImplicitFiniteDifference() {
		ImplicitFiniteDifferenceImpl implicitFiniteDifference = new ImplicitFiniteDifferenceImpl();
		return implicitFiniteDifference;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BlackScholes createBlackScholes() {
		BlackScholesImpl blackScholes = new BlackScholesImpl();
		return blackScholes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BaseType createBaseTypeFromString(EDataType eDataType, String initialValue) {
		BaseType result = BaseType.get(initialValue);
		if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertBaseTypeToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OptionModelPackage getOptionModelPackage() {
		return (OptionModelPackage)getEPackage();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @deprecated
	 * @generated
	 */
	@Deprecated
	public static OptionModelPackage getPackage() {
		return OptionModelPackage.eINSTANCE;
	}

} //OptionModelFactoryImpl
